#include "PackType.h"

#include <stdint.h>




PackType::PackType(uint8_t *data, size_t length)
    :std::basic_string<uint8_t>(data,length)
{
}

std::string PackType::toString()
{
    std::string hexStr;
    for( size_t i=0; i< this->length(); ++i ){
        hexStr.append( toHexString(this->at(i)) );
        if( i+1 != this->length() ){
            hexStr.append(",");
        }
    }

    return hexStr;
}

std::string PackType::toHexString(uint8_t data)
{
    char hexStr[5]={0};

    std::snprintf(hexStr,5,"0x%02x",data);

    return std::string(hexStr);
}

